import { baseUrl } from "./config.js"

// 首页榜单的接口请求
export function getTopList(){
	// let listIds=['3','0','2','1'] // idx
	
	// Promise对象里面是一个异步操作
	// return new Promise(function(resolve,reject){
	// 	uni.request({
	// 		url:`${baseUrl}/toplist/detail`,
	// 		method:'GET',
	// 		success:(res)=>{
	// 			let result=res.data.list.slice(0,4)
	// 			for(let i=0;i<listIds.length;i++){
	// 				result[i].listId=listIds[i]
	// 			}
	// 			resolve(result)
	// 		}
	// 	})
	// }
	return uni.request({
		url:`${baseUrl}/toplist/detail`,
		method:'GET',
	})
}

// 榜单详情页的数据请求
export function getSongList(listId){
	return uni.request({
		url:`${baseUrl}/playlist/detail?id=${listId}`,
		method:'GET'
	})
} 

// 歌曲的数据请求
export function getSongDetail(songId){
	return uni.request({
		url:`${baseUrl}/song/detail?ids=${songId}`,
		methods:'GET'
	})
}

// 获取相似歌曲 
export function getSimiSong(songId){
	return uni.request({
		url:`${baseUrl}/simi/song?id=${songId}`,
		methods:'GET'
	})
}

// 获取歌曲评论
export function getSongComment(songId){
	return uni.request({
		url:`${baseUrl}/comment/music?id=${songId}`,
		methods:'GET'
	})
}

// 获取歌词
export function getSongLyric(songId){
	return uni.request({
		url:`${baseUrl}/lyric?id=${songId}`,
		methods:'GET'
	})
}

// 歌曲MP3的url
export function getSongUrl(songId){
	return uni.request({
		url:`${baseUrl}/song/url?id=${songId}`,
		methods:'GET'
	})
}

// 热搜列表
export function getHotSearch(){
	return uni.request({
		url:`${baseUrl}/search/hot/detail`,
		method:'GET'
	})
}

// 搜索结果
export function getSearchResult(word){
	return uni.request({
		url:`${baseUrl}/search?keywords=${word}`,
		method:'GET'
	})
}

// 搜索建议
export function getSearchSuggestion(word){
	return uni.request({
		url:`${baseUrl}/search/suggest?keywords=${word}&type=mobile`,
		method:'GET'
	})
}
